-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use hardcoded path to i18n file if not provided #290
Use hardcoded path to i18n file if not provided #290
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good solution, but maybe we should also revert moving the files in the src
directory, at least for now?
Otherwise it will only work if we release Gherkin and Behat at the same time (and bump the minimum version requirement in Behat).
Also Behat may not be the only thing using this class with a path to the Gherkin i18n file - I'm not sure the limited benefit we get from flattening the directory structure is worth even a small risk of causing problems for other people?
19bef0e
to
6bdc5fa
Compare
@acoulton I think that moving the files is a good move that we should keep. No one should have been depending on the location of files, and if they did they would need to work to fix that unnecessary dependency. But it is true that currently this makes the update cumbersome, having to release Gherkin and Behat at the same time. What I think we could do:
What do you think? |
Normally I would agree (and did when I merged #288). However, discovering now that we ship a class that it seems would always/usually need to be used with a path in this repo it seems a little more reasonable that people might have being doing that... But I think your solution is good, I think the majority of users will be using this with Behat so as long as that upgrade path is smooth that's probably ok. |
6bdc5fa
to
b4e3dff
Compare
@acoulton I created the new release branch, modified this PR to point to the new branch and modified the code to point to the old location |
@carlos-granados thanks - I noticed there's a test that was also specifying the path (both in the setup and the assertions). I've pushed a commit to your branch that removes the constructor argument, so that should test should now prove that the default file location is correct (it will fail when the files are moved). While doing that, I wondered if it would be clearer to use a named constructor rather than an optional argument - something like: public static function withGherkinI18n(): self {
// or maybe withDefaultKeywords // withDefaultTranslations?
return new self(__DIR__ . '/../../../../i18n.php');
}
// and then leave the constructor parameter required. That way it's explicit to end users what this class does with a null / missing constructor argument - What do you think? |
Good idea, I think that |
I can update that in this PR, unless you want to? |
Yes, please, go ahead I am busy with something else at the moment |
Allows end-users to create an instance with the i18n file provided by us, without an external dependency on the path to the file. Co-authored-by: Carlos Granados <[email protected]>
@carlos-granados done - let me know if this looks OK to you and I can squash-merge and do the release notes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @acoulton
Alternate solution to the problem described in Behat/Behat#1602 and Behat/Behat#1603. Since the file that
CachedArrayKeywords
needs to load is in the same package, it does not need to be told its location by another package. We keep the option of passing a file name in case someone is using this class to load an i18n file from some other location. After this is merged in this package we should update Behat so that it does not attempt to provide the path to the file